package services

import (
	"github.com/mlogclub/simple/sqls"
	"github.com/mlogclub/simple/web/params"

	"bbs-go/internal/models"
	"bbs-go/internal/repositories"
)

var ResourcesTypesService = newResourcesTypesService()

func newResourcesTypesService() *resourcesTypesService {
	return &resourcesTypesService{}
}

type resourcesTypesService struct {
}

func (s *resourcesTypesService) Get(id int64) *models.ResourcesTypes {
	return repositories.ResourcesTypesRepository.Get(sqls.DB(), id)
}

func (s *resourcesTypesService) Take(where ...interface{}) *models.ResourcesTypes {
	return repositories.ResourcesTypesRepository.Take(sqls.DB(), where...)
}

func (s *resourcesTypesService) Find(cnd *sqls.Cnd) []models.ResourcesTypes {
	return repositories.ResourcesTypesRepository.Find(sqls.DB(), cnd)
}

func (s *resourcesTypesService) FindPageByParams(params *params.QueryParams) (list []models.ResourcesTypes, paging *sqls.Paging) {
	return repositories.ResourcesTypesRepository.FindPageByParams(sqls.DB(), params)
}

func (s *resourcesTypesService) FindPageByCnd(cnd *sqls.Cnd) (list []models.ResourcesTypes, paging *sqls.Paging) {
	return repositories.ResourcesTypesRepository.FindPageByCnd(sqls.DB(), cnd)
}

func (s *resourcesTypesService) Create(t *models.ResourcesTypes) error {
	return repositories.ResourcesTypesRepository.Create(sqls.DB(), t)
}

func (s *resourcesTypesService) Update(t *models.ResourcesTypes) error {
	return repositories.ResourcesTypesRepository.Update(sqls.DB(), t)
}

func (s *resourcesTypesService) Updates(id int64, columns map[string]interface{}) error {
	return repositories.ResourcesTypesRepository.Updates(sqls.DB(), id, columns)
}

func (s *resourcesTypesService) UpdateColumn(id int64, name string, value interface{}) error {
	return repositories.ResourcesTypesRepository.UpdateColumn(sqls.DB(), id, name, value)
}

func (s *resourcesTypesService) Delete(id int64) error {
	return repositories.ResourcesTypesRepository.Delete(sqls.DB(), id)
}

func (s *resourcesTypesService) FindSimpleAllList() (list []models.ResourcesTypes, err error) {
	return repositories.ResourcesTypesRepository.FindSimpleAllList(sqls.DB())
}
